home *** CD-ROM | disk | FTP | other *** search
- Q32557 Comparison of Result of Pointer Subtraction Inconsistent
- C Compiler
- 5.10 | 5.10
- MS-DOS | OS/2
-
- Summary:
- The following program attempts to compare two pointers. When the
- value is assigned to a variable, the comparison works correctly;
- however, when the comparison is performed directly to zero, the test
- fails.
- The compiler is incorrectly making a signed comparison of the
- pointers b and a.
- Microsoft has confirmed this to be a problem in Version 5.10 of the
- C compiler. We are researching this problem and will post new
- information as it becomes available.
- You can work around this problem by using the first form; i.e., make
- the assignment of the comparison to a variable and then check that
- value against zero.
-
- More Information:
- The following program demonstrates the problem:
-
- #include <stdio.h>
- #include <dos.h>
- main()
- {
- unsigned char far *a,far *b;
- int a;
- FP_SEG(a) = 0x1baf;
- FP_OFF(a) = 0x7f32;
- FP_SEG(b) = 0x1baf;
- FP_OFF(b) = 0x8446;
-
- if((a = b-a)>0)
- printf("(a = b-a) is OK\n");
- if((b-a) > 0)
- printf("(b-a) is OK\n");
- else
- printf("(b-a) is not OK\n");
- }
-
-
-
- Keywords: buglist5.10 qfbv
- Updated 88/07/21 03:19
-